<?php

namespace App\Console\WxtjCommands;

use App\Services\WxtjUser;
use Illuminate\Console\Command;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputArgument;

class UserSummary extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'wxtj-user:summary 
            {beginDate? : 获取数据的起始日期.}
            {endDate? : 获取数据的结束日期.}
            {--all : 是否拉取所有数据}';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = '微信用户分析数据统计：拉取指定日期范围内用户增减数据';

    protected $wxtjUser;
    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct(WxtjUser $wxtjUser)
    {
        parent::__construct();
        $this->wxtjUser = $wxtjUser;
    }
    /**
     * Execute the console command.
     *
     * @return mixed
     */
    public function handle()
    {
        $isAll = $this->option('all');
        if ($isAll){
            $this->wxtjUser->pullAllSummary();
        }else{
            $beginDate = $this->argument('beginDate');
            $endDate = $this->argument('endDate');
            $this->wxtjUser->pullSummary($beginDate, $endDate);
        }
    }
}
